<?php
// +----------------------------------------------------------------------
// | Author: 林子彦
// +----------------------------------------------------------------------
namespace Lapi\Model;
use Think\Model;
/**
 * 会员模型
 */
class OnlineCourseModel extends Model{
	protected $_auto = array(		
			array('status',1, 3),
			array('create_time', NOW_TIME, 3),
			array('update_time', NOW_TIME, 3)
	);
   public function addData($data){
   	$data["status"]=1;
   	$data["create_time"]=NOW_TIME;
   	$data["update_time"]=NOW_TIME;
   	if($this->create($data)){
   		if($this->add($data)){
   			return $this->success("操作成功","index");
   		}else{
   			return $this->error("操作失败");
   		}
   	}else{
   		return $this->error($this->getMessage());
   	}
   }
   public function saveData($data){
   	$data["status"]=1;
   	$data["create_time"]=NOW_TIME;
   	$data["update_time"]=NOW_TIME;
   	if($this->create($data)){
   		if($this->save($data)){
   			return $this->success("操作成功","index");
   		}else{
   			return $this->error("操作失败");
   		}
   	}else{
   		return $this->error($this->getMessage());
   	}
   }
   public function delData($id){
   	  if($this->where(array("id"=>$id))->delete()){
   	  	return $this->success("操作成功", "index");
   	  }else{
   	  	return $this->error("操作失败");
   	  }
   }
   
   /**
    * 错误提醒
    * @param unknown $message
    * @param unknown $jumpUrl
    * @return string
    */
   
   public function error($message,$jumpUrl){
   	$data           =   array();
   	$data['msg']   =   $message;
   	$data['code'] =   0;
   	$data['url']    =   $jumpUrl;
   	return  json_encode($data);
   }
   public function success($message,$jumpUrl){
   	$data           =   array();
   	$data['msg']   =   $message;
   	$data['code'] =   1;
   	$data['url']    =   $jumpUrl;
   	
   	return  json_encode($data);
   	
   }
    

}
